language detecte by browser ( exception api url )

storeid='';
if(!$_SERVER['REQUEST_URI']=='/api/v2_soap/?wsdl')
{
    $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
    switch ($lang) {
        case "fr":

            $storeid = 2;
            break;
        case "en":
            //echo "PAGE EN";
            $storeid = 1;
            break;
        default:
            $storeid = 1;
            break;
    }
}
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : $storeid;

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Leave a Comment